﻿using System.Net.Mail;

namespace Infrastructure.Coding
{
    public class MailManagement
    {
        private const string adminMail = "nitsoca@gmail.com";
        private const string vanzariMail = "vanzari@scaune-ieftine.ro";
        private const string infoMail = "info@scaune-ieftine.ro";
        private const string officeMail = "office@scaune-ieftine.ro";

        public void SendMail(string bodyMessage, string to, string subject)
        {
            //MailMessage mail = new MailMessage
            //{
            //    Body = bodyMessage,
            //    To = to,
            //    BodyFormat = MailFormat.Html,
            //    Subject = subject,
            //    Bcc = adminMail
            //};
            //SmtpMail.SmtpServer = smtpServer;
            //// - smtp.gmail.com use smtp authentication
            //mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            //mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", user);
            //mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
            //// - smtp.gmail.com use port 465 or 587
            //mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
            //// - smtp.gmail.com use STARTTLS (some clients call this SSL)
            //mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
            //SmtpMail.Send(mail);
            ///
            /// //AlternateView view = AlternateView.CreateAlternateViewFromString(mail.Body, null, "text/html");
            //mail.IsBodyHtml = true;

            SmtpClient smtpClient = new SmtpClient();
            MailMessage message = new MailMessage();
            MailAddress fromAddress = new MailAddress("nitsoca@gmail.com");

            //smtpClient.Host = "89.38.209.22";
            //smtpClient.Credentials=
            ////new NetworkCredential ( "admin", "scauneieftine" );
            //smtpClient.UseDefaultCredentials = false;
            //smtpClient.Port = 25;
            //smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;qA
            
            message.From = fromAddress;
            message.To.Add(to);
            message.Subject = subject;
            message.Body = bodyMessage;
            message.IsBodyHtml = true;
            message.Bcc.Add(adminMail);
            message.Bcc.Add(vanzariMail);
            message.Bcc.Add(infoMail);
            message.Bcc.Add(officeMail);
            smtpClient.Send(message);
        }
    }
}
